package com.lpz.wdbc.util;

import java.util.Random;

public class StringUtils {
	
	/**
	 * 是否为空字符
	 * @param str
	 * @return
	 */
	public static boolean isEmpty(String str){
		if(str == null) return true;
		if("".equals(str.trim())) return true;
		
		return false;
	}
	
	
	
	public static String genValiCode(){
		
		int r = new Random().nextInt(999999);
		if(r < 100000) r += new Random().nextInt(9) * 100000;
		
		return String.valueOf(r);
	}
	
	
	 public static final char UNDERLINE='_';  
	 
	 public static String camelToUnderline(String param){  
	        if (param==null||"".equals(param.trim())){  
	            return "";  
	        }  
	        int len=param.length();  
	        StringBuilder sb=new StringBuilder(len);  
	        for (int i = 0; i < len; i++) {  
	            char c=param.charAt(i);  
	            if (Character.isUpperCase(c)){  
	                sb.append(UNDERLINE);  
	                sb.append(Character.toLowerCase(c));  
	            }else{  
	                sb.append(c);  
	            }  
	        }  
	        return sb.toString();  
	    }
	 
	 
	 
	 public static String getGetterName(String proprty){
	     char[] chars = proprty.toCharArray();
	     char c = chars[0];
	     c = Character.toUpperCase(c);
	     chars[0] = c;
	     StringBuilder nameBuilder = new StringBuilder("get");
	     return nameBuilder.append(chars).toString();
	 }
	 
	 public static String getSetterName(String proprty){
	     char[] chars = proprty.toCharArray();
	     char c = chars[0];
	     c = Character.toUpperCase(c);
	     chars[0] = c;
	     StringBuilder nameBuilder = new StringBuilder("set");
	     return nameBuilder.append(chars).toString();
	 }
	 
	 public static String getIsName(String proprty){
	     char[] chars = proprty.toCharArray();
	     char c = chars[0];
	     c = Character.toUpperCase(c);
	     chars[0] = c;
	     StringBuilder nameBuilder = new StringBuilder("is");
	     return nameBuilder.append(chars).toString();
	 }
	    
	 
	
}
